package dao;

import java.util.List;

import model.*;
import model.Process;

public class DAOUser extends DAOJPA<Users> {
	
	public DAOUser(){
		super();
	}
	
	//find user by username and password
	
	public Users validateUser(String username, String password){
		return (Users) super.findByQuery("select u from Users u where u.username = \'" + username + "\' and u.password = \'" + password + "\'");
	}
	
	//find user by name
	public Users findByName(String name) {
		return (Users) super.findByQuery("select u from Users u where u.name = \'" + name + "\'");
	}
	
	
	//find user's process by username
	public List<Process> findProcessByUsername(String username){
		return (List<Process>) super.findByQuery("select u.processes from Users u where u.username = \'" + username + "\'");
	}
}
